<template>
    <div>
        随机增加:
        <Counter :number="number"></Counter>
		
		Ajax:
		<Ajax></Ajax>
    </div>
</template>
<script>
    import Counter from './counter.vue';
	import Ajax from './ajax.vue';

    export default {
        components: {
            Counter,
			Ajax
        },
        data() {
            return {
                number: 0
            }
        },
        created() {
            this.$bus.on('add', this.handleAddRandom);
        },
        beforeDestory() {
            this.$bus.off('add', this.handleAddRandom);
        },
        methods: {
            handleAddRandom(num) {
                this.number += num;
            }
        }
    }
</script>
